At First we will simulate two time series.
- generate two random stochastic processes
- generate a cointegration series
- statistical tesy and ADF test
2019/9/1
At First we will simulate two time series.
library(plotly) library(tidyverse) set.seed(42) N = 1000 x = cumsum(rnorm(N)) gamma = 0.7 y = gamma * x + rnorm(N)
Now we will use ADF-test for check the stationarity by urca package.
library(urca) summary(ur.df(x, type = 'none')) summary(ur.df(y, type = 'none'))
From the result we cannot reject H0 hypothesis that two series are unit root process.
In this part we will generate a linear combination series with x and y. Then we will use ADF-test on this new series.
z = y - gamma * x ur.df(z, type='none')
## ## ############################################################### ## # Augmented Dickey-Fuller Test Unit Root / Cointegration Test # ## ############################################################### ## ## The value of the test statistic is: -22.2053
Now we can see this combination series is stationarity.